/* eslint-disable @typescript-eslint/no-explicit-any */
import type { OptionInterface } from "./index.d";
import type { App } from "vue";
// import { defineAsyncComponent } from "vue";
import table from "./table/index.vue";
import myloading from "./loading/index";
import xForm from "./create_form/index.vue";
import xUpload from "./upload/index.vue";
import xCopy from "./c_copy/index.vue";
import { config } from "./config";
// const modules = import.meta.glob("./**/index.vue");

// const modulekeys = Object.keys(modules);
const modulekeys = [table, xForm, xUpload, xCopy];
export const loading = myloading;
const MyUi: any = {};
// const reg = /\/(.*)\//g;
MyUi.install = function (app: App<Element>, options: OptionInterface) {
  config.uploadUrl = options.uploadUrl;
  // console.log(options);
  if (options.dealTableRes) {
    config.dealTableRes = options.dealTableRes;
  }
  if (options.dealTableSearch) {
    config.dealTableSearch = options.dealTableSearch;
  }
  modulekeys.forEach(async (k) => {
    // console.log(com.name);
    // const com = modules[k];
    // const name = k.split("/")[1];
    // app.component(com.name, com);

    app.component(k.name, k);
  });
};
export default MyUi;
